import 'package:app/common/colors.dart';
import 'package:app/common/tool.dart';
import 'package:app/components/base_scaffold_appbar.dart';
import 'package:app/services/address.dart';
import 'package:app/services/dio_manager.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../common/app_theme.dart';
class CooperateDetailPage extends StatefulWidget {

  var employee_id;


  CooperateDetailPage(this.employee_id);

  @override
  State<CooperateDetailPage> createState() => _CooperateDetailPageState();
}

class _CooperateDetailPageState extends State<CooperateDetailPage> {

  CooperateDetailModel? model;

  requestData()async{

    var json = await DioManager().kkRequest('${Address.hrEmployeeReads}/${widget.employee_id}',method: 'get');

    CooperateDetailModel _model = CooperateDetailModel.fromJson(json);

    model = _model;

    setState(() {

    });
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    requestData();
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColor.bgColor,
      appBar: BaseAppBar(
        preferredSize: Size(Get.width, AppTool.appBarHEIGHT),
        child: Text('联系人详情'),
      ),
      body: ListView(
        children: [
          SizedBox(height: 15,),
          Container(
              padding: EdgeInsets.only(left: 15,right: 15),
              color: Colors.white,
              alignment: Alignment.centerLeft,
              height: 40,
              child:  Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text('账号',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                  Text('${model?.data?.account??''}'),
                ],
              )
          ),
          SizedBox(height: 1,),
          Container(
              padding: EdgeInsets.only(left: 15,right: 15),
              color: Colors.white,
              alignment: Alignment.centerLeft,
              height: 40,
              child:  Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text('员工名称',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                  Text('${model?.data?.name??''}'),
                ],
              )
          ),
          SizedBox(height: 1,),
          Container(
              padding: EdgeInsets.only(left: 15,right: 15),
              color: Colors.white,
              alignment: Alignment.centerLeft,
              height: 40,
              child:  Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text('工作手机',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                  Text('${model?.data?.mobile??''}'),
                ],
              )
          ),
          SizedBox(height: 1,),
          Container(
              padding: EdgeInsets.only(left: 15,right: 15),
              color: Colors.white,
              alignment: Alignment.centerLeft,
              height: 40,
              child:  Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text('工作电话',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                  Text('${model?.data?.phone??''}'),
                ],
              )
          ),
          SizedBox(height: 1,),
          Container(
              padding: EdgeInsets.only(left: 15,right: 15),
              color: Colors.white,
              alignment: Alignment.centerLeft,
              height: 40,
              child:  Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text('email',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                  Text('${model?.data?.email??''}'),
                ],
              )
          ),
          SizedBox(height: 1,),
          Container(
              padding: EdgeInsets.only(left: 15,right: 15),
              color: Colors.white,
              alignment: Alignment.centerLeft,
              height: 40,
              child:  Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text('部门名称',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                  Text('${model?.data?.department??''}'),
                ],
              )
          ),
          SizedBox(height: 1,),
          Container(
              padding: EdgeInsets.only(left: 15,right: 15),
              color: Colors.white,
              alignment: Alignment.centerLeft,
              height: 40,
              child:  Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text('公司',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                  Text('${model?.data?.company??''}'),
                ],
              )
          ),
          SizedBox(height: 1,),
          Container(
              padding: EdgeInsets.only(left: 15,right: 15),
              color: Colors.white,
              alignment: Alignment.centerLeft,
              height: 40,
              child:  Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text('岗位',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                  Text('${model?.data?.job??''}'),
                ],
              )
          ),
        ],
      ),
    );
  }
}
class CooperateDetailModel {
  int? errcode;
  String? errmsg;
  Data? data;
  String? message;

  CooperateDetailModel({this.errcode, this.errmsg, this.data, this.message});

  CooperateDetailModel.fromJson(Map<String, dynamic> json) {
    errcode = json['errcode'];
    errmsg = json['errmsg'];
    data = json['data'] != null ? new Data.fromJson(json['data']) : null;
    message = json['message'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['errcode'] = this.errcode;
    data['errmsg'] = this.errmsg;
    if (this.data != null) {
      data['data'] = this.data!.toJson();
    }
    data['message'] = this.message;
    return data;
  }
}

class Data {
  int? id;
  String? account;
  String? name;
  String? mobile;
  String? phone;
  String? email;
  String? department;
  String? company;
  String? job;
  String? image128;

  Data(
      {this.id,
        this.account,
        this.name,
        this.mobile,
        this.phone,
        this.email,
        this.department,
        this.company,
        this.job,
        this.image128});

  Data.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    account = json['account'];
    name = json['name'];
    mobile = json['mobile'];
    phone = json['phone'];
    email = json['email'];
    department = json['department'];
    company = json['company'];
    job = json['job'];
    image128 = json['image128'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['account'] = this.account;
    data['name'] = this.name;
    data['mobile'] = this.mobile;
    data['phone'] = this.phone;
    data['email'] = this.email;
    data['department'] = this.department;
    data['company'] = this.company;
    data['job'] = this.job;
    data['image128'] = this.image128;
    return data;
  }
}
